package com.camps.sdk.decrypt;

import com.camps.sdk.common.Constants;
import com.camps.sdk.entity.DeviceUpMessage;
import com.camps.sdk.entity.UpStep;
import com.camps.sdk.utils.LocationUtils;

import java.util.List;

/**
 * @Author ldaoliang
 * @Date create in 15:58 2021/9/1
 * @Description
 */
public class AnalyzeUpStep implements AnalyticalData {
    @Override
    public DeviceUpMessage parseData(String originalData)
    {
        // 解析到指令：*WT,800115470000876,STEP,120057,0,82,160621,FDFFFFFF
        //解密
        String[] split = parseCommand(originalData);
        String imei = split[1];
        String commandNumber = split[3];
        String stepNum = split[4];//步数
        String battery = split[5];  // 电量
        String date = split[6];//日月年
        String deviceStatus = split[7];
        UpStep upStep = new UpStep();
        upStep.setBattery(Integer.parseInt(battery));
        upStep.setCommandNumber(commandNumber);
        upStep.setImei(imei);
        upStep.setDeviceDate(date);
        upStep.setStepNum(Integer.parseInt(stepNum));
        upStep.setDeviceTime(commandNumber);
        upStep.setDeviceStatus(deviceStatus);
        String str="*WT,".concat(imei).concat(",STEP,").concat(commandNumber).concat(",STEP_GET#");
        return structureMessage(Constants.UPLOAD,Constants.UP_STEP,true,str,upStep);
    }
}
